package com.plan.controller.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.plan.commen.bean.User;
import com.plan.commen.entity.ApiResult;
import com.plan.commen.entity.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @PACKAGE_NAME: com.plan.controller.controller
 * @NAME: IndexController
 * @USER: 冯政尚
 * @DATE: 2020/11/30
 * @TIME: 19:29
 * @DAY_NAME_SHORT: 周一
 * @PROJECT_NAME: four_plan
 */
@RequestMapping(value = "index")
@Controller
public class IndexController extends BaseController {


    @RequestMapping(value = "login.html")
    public String login(){
        return "login";
    }

    @RequestMapping(value = "index.html")
    public String index(){
        return "index";
    }

    /**
     * @param account
     * @param passWord
     * @return 登录
     */
    @RequestMapping(value = "loginSystem")
    @ResponseBody
    public ApiResult loginSystem(String account,String passWord){
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("account",account);
        queryWrapper.eq("pass_word",passWord);
        User user = userService.getOne(queryWrapper);
        if(user!=null){
            return ApiResult.ok();
        }
        return ApiResult.fail();
    }

    @RequestMapping(value = "index2.html")
    public String index2(){
        return "index/index2";
    }
    @RequestMapping(value = "ui-accordions.html")
    public String ui_accordions(){
        return "index/ui-accordions";
    }
    @RequestMapping(value = "ui-alerts.html")
    public String alerts(){
        return "index/ui-alerts";
    }
    @RequestMapping(value = "ui-bootstrap-elements.html")
    public String a(){
        return "index/ui-bootstrap-elements";
    }

    @RequestMapping(value = "user.html")
    public String user(Model model){
        List<User> list = userService.list();
        model.addAttribute("user",list);
        return "user/user";
    }
}
